<!DOCTYPE html>
<html>

<head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta charset="utf-8">
  <title></title>
  <meta name="keywords" content="">
  <meta name="description" content="">
  <meta name="author" content="">
  <link href="css/daterangepicker.min.css" rel="stylesheet">
  <link rel="stylesheet" href="css/main_2.css">
  <link rel="stylesheet" href="css/lcommon.css">
  <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
  <!--[if lt IE 9]>
	<script src="js/html5shiv.min.js"></script>
	<script src="js/respond.min.js"></script>
<![endif]-->
  <meta name="renderer" content="webkit">
  <link rel="shortcut icon" href="favicon.ico">
</head>

<body>
  <div id="app" v-cloak v-loading="loading">
    <header id="header">

    </header>
    <div class="header-space"></div>

    <!-- 搜索框 -->
    <section class="section61">
      <div class="content">
        <div class="search-box">
          <div class="con">
            <input type="text" id="searchText" class="input" placeholder="请输入职位/公司名称">
            <input @click="toSearch()" type="submit" value="搜索" class="btn btn-white">
          </div>
          <p>热门搜索：
            <template v-if="hot_keyword">
              <a @click="toSearch(item)" href="javascript:void(0)" v-for="(item, i) in hot_keyword"
                :key="i">{{item + (i==hot_keyword.length-1? "" : "、")}}</a>
            </template>
          </p>
        </div>
      </div>
    </section>
    <!-- 职位分类 -->
    <section class="section62">
      <div class="content">
        <div class="menu" v-if="position">
          <div class="firstMenu" v-for="(item, i) in position" :key="i">
            <b>{{item.name}}</b>
            <a @click="toSearch(c1.name)" href="javascript:void(0)" v-for="(c1, k) in item.children" v-if="i<4"
              :key="k">{{c1.name}}</a>
            <div class="secondMenu">
              <template v-for="(c1, k) in item.children">
                <h3 :key="k"><a @click="toSearch(c1.name)" href="javascript:void(0)">{{c1.name}}</a></h3>
                <div class="con">
                  <a href="javascript:void(0)" @click="toSearch(c2.name)" v-for="(c2, j) in c1.children"
                    :key="j">{{c2.name}}</a>
                </div>
              </template>
            </div>
          </div>

          <div class="btm">
            <a class="btn-showMore">显示全部分类</a>
          </div>
        </div>
        <div class="banner-box">
          <div class="js_bannerLeft banner">
            <div class="hd">
              <ul>
                <li  v-for="(item, i) in banner" :key="i"></li>
              </ul>
            </div>
            <div class="bd">
              <ul>
                <li v-for="(item, i) in banner"><a :href="item.url"><img :src="item.img" alt="" class="cover"></a></li>
              </ul>
            </div>
          </div>
        </div>
      </div>
    </section>
    <!-- 招聘信息 -->
    <section class="section63">
      <div class="content">
        <div class="g-titleLine">
          <h3>招聘信息</h3>
          <p>Recruitment</p>
          <div class="line"></div>
        </div>
        <div class="list">

          <div @click="link('07.html?id='+ item.id)" class="item" v-for="(item, i) in recruit" :key="i">
            <h3><a href="javascript:void()0"><b>{{item.name}}</b></a> <span class="orange">{{item.salary_min}}-{{item.salary_max}}K</span>
            </h3>
            <div class="con">
              {{item.educationName}} | {{getNatureName(item.type)}} |
              {{item.experienceConfigName.max==0? item.experienceConfigName.min + "年以上" : item.experienceConfigName.min==0? item.experienceConfigName.max + "年以下" : (item.experienceConfigName.min+"-"+item.experienceConfigName.max+"年") }}
              <time>{{item.createdFrom=="几秒前"?'刚刚':item.createdFrom}}</time>
            </div>
            <div class="tags" v-if="item.recruit_welfare">
              <span v-for="(tag, k) in item.recruit_welfare" :key="k" class="tag">{{tag.welfareName}}</span>
            </div>
            <div class="user">
              <a @click.stop="link('08.html?id='+ item.enterprise.id)" href="javascript:void(0)">
                <img :src="item.enterprise.logo" alt="" class="face">
                <h4>{{item.enterprise.name}}</h4>
                <p>{{getAddr(item.area_id)}} | {{item.enterprise.typeName}}</p>
              </a>
            </div>
          </div>
        </div>
        <div class="operate">
          <a @click="link('25.html')" href="javascript:void(0)" class="arrow blue">查看更多</a>
        </div>
      </div>
    </section>
    <section class="section64">
      <div class="content">
        <div class="g-titleLine white">
          <h3>最新活动</h3>
          <p>activity</p>
          <div class="line"></div>
        </div>
      </div>
    </section>
    <section class="section65">
      <div class="content">
        <div class="list">
          <div class="item" @click="link('10.html?id='+ item.id)" v-for="(item, i) in activity" :key="i" v-if="!showMore?i==0:true">
            <div class="img"><a href="javascript:void(0)"><img :src="item.cover" alt="" class="cover"></a></div>
            <div class="con">
              <div class="line"></div>
              <h3><a href="">{{item.name}}</a></h3>
              <div class="time">{{item.created_at.substring(0,10)}}</div>
              <div class="txt_1">{{item.content}}</div>
            </div>
          </div>
        </div>
        <div class="operate">
          <a v-if="showMore" href="javascript:void(0)" class="arrow blue" @click="link('09.html')">查看更多</a>
          <a v-else href="javascript:void(0)" class="arrow blue" @click="showMore=true">查看更多</a>
        </div>
      </div>
    </section>
    <section class="section66">
      <div class="content">
        <div class="g-titleLine">
          <h3>合作企业</h3>
          <p>Cooperation</p>
          <div class="line"></div>
        </div>
        <div class="js_picScrollLeft picScrollLeft">
          <div class="bd">
            <ul class="picList">
              <li v-for="(item, i) in merchant" :key="i" v-if="showCount(i)"><a :href="item.url"><img :src="item.img" alt="" class="cover"></a></li>
            </ul>
          </div>
          <a class="next" @click="changePage(1)" v-if="setAngle(1)"></a>
          <a class="prev" @click="changePage(-1)" v-if="setAngle(0)"></a>
        </div>
      </div>
    </section>

    <footer id="footer">

    </footer>
  </div>
  <script src="js/jquery.min.js"></script>
  <script src="js/common.js"></script>
  <script src="js/lcommon.js"></script>
  <script src="js/slide.min.js"></script>
  <script src="js/polyfill.min.js"></script>
  <script src="js/jquery.nicescroll3.7.6.min.js"></script>
  <!-- <script src="js/main.js"></script> -->
  <script src="js/vue.js"></script>
  <script src="https://unpkg.com/element-ui/lib/index.js"></script>
  <script src="js/request.js"></script>
  <script src="js/moment.min.js"></script>
  <script src="js/getPrepareData.js"></script>
  <script src="js/moment.locale.js"></script>
  <script>
    $(function () {
      // $("header .menu li").eq(1).addClass('on')
      $("#header").load("./lcommon/header.html");
      $("#footer").load("./lcommon/footer.html");
      $("body").on('click', '.section62 .btn-showMore', function (event) {
        event.preventDefault();
        $(this).parents(".menu").addClass('auto')
      });
      $(".section62 .menu").hover(function () {}, function () {
        $(this).removeClass('auto')
      });
       // 通用：弹框关闭
      $(document).on('click', '.alert .btn-close,.alert .over-close,.alert .js_btn-cancle', function (event) {
        event.preventDefault();
        $(this).parents(".alert").fadeOut('300', function () {
          $(this).removeClass('show');
        });
      }); // 验证码发送
    })

    var vm = new Vue({
      el: '#app',
      data: {
        content: "",
        position: undefined,
        hot_keyword: undefined,
        activity: [], //活动
        recruit: [], //招聘信息
        banner: [],//
        merchant: [],
        loading:true,
        region:[],
        page:0,
        showMore:false
      },
      mounted() {
        var vm = this
        indexprepare(function (data) {
          vm.position = data.position
          vm.region = data.region
          vm.hot_keyword = data.hot_keyword
          vm.base_info()
        })
      },
      methods: {
        showCount(index){
          var flag = ((this.page-1) * 5) + 5
          if((index>=flag) && index<(flag+5)){
            return true
          }else{
            return false
          }
        },
        setAngle(flag){
          if(flag){
            // next
            if(this.page<(Math.floor(this.merchant.length / 5))){
              console.log(Math.floor(this.merchant.length / 5))
              return true
            }else{
              console.log("false")
              return false
            }
          }else{
            // prev
            if(this.page>0){
              console.log("true")
                return true
              }else{
                console.log("false")
                return false
              }
          }
        },
        changePage(num){
          this.page += num
        },
        getNameList(id, list, result=[]) {
          var nameKey = 'region_name'
          result = result || [];
          var item, val;
          for(var i =0; i< list.length; i++) {
            item = list[i];
            if(item.id === id) {
              result.push(item[nameKey])
              return result;
            }else if(item.children) {
              vm.getNameList(id, item.children, result);
              if(result.length) {
                result.unshift(item[nameKey]);
                return result
              }
            }
          }
          return result;
        },
        getAddr(area_id){
            var arr = this.getNameList(area_id,this.region)
            return arr.join("-")
        },
        base_info: function (e, num) {
          var vm = this
          var url = "person/index/base_info"
          var p = {

          }
          request(url, 'GET', JSON.stringify({}), function (res) {
            vm.loading = false
            vm.merchant = res.data.merchant
            vm.activity = res.data.activity
            vm.banner = res.data.banner
            var recruit = res.data.recruit
            recruit.forEach(function (v) {
              v.createdFrom = moment(v.updated_at).fromNow()
              v.educationName = getEducationName(v.education_id) //教育程度
              v.experienceConfigName = getExperienceName(v.experience_config_id) //工作年限
              v.enterprise.typeName = getTypeName(v.enterprise.type_id)
              // v.enterprise.tradeName = getTradeName(v.enterprise.trade_id)
              v.recruit_welfare.forEach(function (m) {
                m.welfareName = getWelfareName(m.welfare_id) //岗位福利
              })
            })

            vm.recruit = recruit
            setTimeout(function(){
              jQuery(".js_bannerLeft").slide({
                mainCell: ".bd ul",
                autoPlay: true,
                effect: "leftLoop"
              });
            }, 500)
          }, function (err) {
            vm.loading = false
            vm.$message.error(err.responseJSON.message);
          })
        },
        link(url) {
          location.href = url
        },
        toSearch(val) {
          if (!val) {
            val = $("#searchText").val()
          }
          if (!val) {
            // this.$message.error("请输入关键字搜索");
            return
          }
          this.link("25.html?key=" + val)
        },
        getNatureName(type){
          return getNatureName(type)
        }

      },

    })
  </script>
</body>

</html>